package com.example.day11.homework;

public class PrintCountCharacter {
    public static void main(String[] args) {

        Content content=new Content();
        Thread t1=new Thr1(content);
        Thread t2=new Thr2(content);

        t1.start();
        t2.start();
    }
}
class   Content {
    private int k = 0;
    boolean flag = false;
    public synchronized void PrintCount() {
        for (int i = 1; i <= 52; i++) {
            System.out.print(i);
            k++;
            if (i % 2 == 0) {
                flag = true;
                try {
                    if (flag) {
                        wait();
                    }
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
            notify();
        }
    }

    public synchronized void PrintCharatar() {
        for (char i = 'A'; i <= 'Z'; i++) {
            if (flag == false) {
                try {
                    wait();
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
            System.out.print(i);
            flag=false;
            notify();
        }
    }
}

class  Thr1 extends  Thread {

    private Content content;
    public Thr1(Content content) {
        this.content = content;
    }
    private  int i=0;
    @Override
    public void run() {
            content.PrintCount();
    }
}
class  Thr2 extends  Thread {
    private Content content;
    public Thr2(Content content) {
        this.content = content;
    }
        private  int i=0;
    @Override
    public void run() {
            content.PrintCharatar();


    }
}

